package com.cbarmstrong.Finance;

import java.io.Serializable;
import java.util.Date;

public class SpreadTrade implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Date openDate, closeDate;
	private double open=0, close=0;
	private double position;
	

	public SpreadTrade(Date date, double price, int direction, double spread){
		this.setOpenDate(date);
		this.setOpen(price+(spread*direction));
		position=direction;
	}
	
	public void close(Date date, double close){
		setClose(close);
		setCloseDate(date);
	}
	
	public int getPosition(){
		return (int) position;
	}
	
	public double getProfit(){
		return ((close-open)*position);
	}

	public Date getOpenDate() {
		return openDate;
	}
	
	public Date getCloseDate() {
		return closeDate;
	}

	private void setOpenDate(Date date) {
		this.openDate = date;
	}

	private void setCloseDate(Date date) {
		this.closeDate = date;
	}

	public double getOpen() {
		return open;
	}

	public double getClose() {
		return close;
	}

	private void setOpen(double open) {
		this.open = open;
	}

	private void setClose(double close) {
		this.close = close;
	}
	
}
